package com.flyme.common.rpc.support;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/**
 * @author liyanxin
 */
public class ServiceManager {
    private static ServiceManager serviceManager = new ServiceManager();

    private ConcurrentMap<String, ServiceMetadata> cache = new ConcurrentHashMap<String, ServiceMetadata>();

    public static ServiceManager getInstance() {
        return serviceManager;
    }

    private ServiceManager() {
    }

    public boolean exists(String key) {
        return cache.containsKey(key);
    }

    public ServiceMetadata get(String key) {
        return cache.get(key);
    }

    public void put(String key, ServiceMetadata value) {
        this.cache.put(key, value);
    }

    public void remove(String key) {
        this.cache.remove(key);
    }
}
